<<<<<<< .mine
#pragma once

#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/set.hpp>
#include "entry_manager.h"
#include "persistance.h"

template<typename EntryT, template<typename EntryT> class IndexT1,
=======
#pragma once

#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/set.hpp>
#include "entry_manager.h"
#include "persistance.h"

template<typename EntryT,
template<typename EntryT> class IndexT1,
>>>>>>> .r33
template<typename EntryT> class IndexT2 = IndexNone2,
<<<<<<< .mine
template<typename EntryT> class IndexT3 = IndexNone3>
class PersistentEntryManager : public EntryManager<IndexT1, IndexT2, IndexT3>
{
	typedef EntryManager<IndexT1, IndexT2, IndexT3> Base;

public:
	PersistentEntryManager(void);
	~PersistentEntryManager(void);

=======
template<typename EntryT> class IndexT3 = IndexNone3 >
class PersistentEntryManager : public EntryManager<EntryT, IndexT1, IndexT2, IndexT3>
{
	typedef EntryManager<EntryT, IndexT1, IndexT2, IndexT3> Base;

public:
	PersistentEntryManager(void);
	~PersistentEntryManager(void);

>>>>>>> .r33
	bool Add(EntryT* entity){
		if( Base::Add(entity) ){
			m_handle_set->insert(ManagedMemory::Instance().get_handle_from_address(entity->pdata()));
			return true;
		}
		else {
			return false;
		}
	}

	void Remove(EntryT* entity){
		m_handle_set->erase(ManagedMemory::Instance().get_handle_from_address(entity->pdata()));
		Base::Remove(entity);
	}

	void Clear(){
		m_handle_set->clear();
		Base::Clear();
<<<<<<< .mine
	}

	bool Restore(){
		const ManagedMemoryAllocator alloc_inst(ManagedMemory::Instance().get_segment_manager());

		m_handle_set = ManagedMemory::Instance().construct<ManagedMemorySet>(typeid(*this).name(), alloc_inst);
		if(!m_handle_set)
			return false;

		ManagedMemorySetIt it = m_handle_set->first();
		for(; it != m_handle_set->end(); ++it)
		{
			void * data = ManagedMemory::type_t::get_address_from_handle(*it);
			Base::Add(new EntryT(data));
		}
	}

private:
	typedef boost::interprocess::allocator<
		ManagedMemory::type_t::handle_t,
		ManagedMemory::type_t::segment_manager>
		ManagedMemoryAllocator;

	typedef boost::interprocess::set<
		ManagedMemory::type_t::handle_t,
		ManagedMemoryAllocator>
		ManagedMemorySet;

	typedef ManagedMemorySet::iterator ManagedMemorySetIt;

	ManagedMemorySet *m_handle_set;
};
=======
	}

	bool Restore(){
		const ManagedMemoryAllocator alloc_inst(ManagedMemory::Instance().get_segment_manager());

		m_handle_set = ManagedMemory::Instance().construct<ManagedMemorySet>(typeid(*this).name(), alloc_inst);
		if(!m_handle_set)
			return false;

		ManagedMemorySetIt it = m_handle_set->first();
		for(; it != m_handle_set->end(); ++it)
		{
			void * data = ManagedMemory::type_t::get_address_from_handle(*it);
			Base::Add(new EntryT(data));
		}
	}

private:
	typedef boost::interprocess::allocator<
		ManagedMemory::type_t::handle_t,
		ManagedMemory::type_t::segment_manager>
		ManagedMemoryAllocator;

	typedef boost::interprocess::set<
		ManagedMemory::type_t::handle_t,
		ManagedMemoryAllocator>
		ManagedMemorySet;

	typedef ManagedMemorySet::iterator ManagedMemorySetIt;

	ManagedMemorySet *m_handle_set;
};

>>>>>>> .r33
